package com.gg.fmallspringboot.controller;

import com.gg.fmallspringboot.entity.Product;
import com.gg.fmallspringboot.model.Result;
import com.gg.fmallspringboot.service.ProductService;
import com.gg.fmallspringboot.service.ProductSkuService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@CrossOrigin
@RequestMapping("/product")
public class ProductController {
    @Resource
    private ProductSkuService productSkuService;
    private ProductService productService;

    public ProductController(ProductService productService) {
        this.productService = productService;
    }

    @GetMapping("/three")
    public Result<Product> getThreeNewProduct(){

        return productService.threeNewProduct();

    }

    @GetMapping
    public Result<Product> getThreeNewProduct2(){

        return productService.selectProductByCategoryId(1);
    }
    @GetMapping("/sku")
    public Result queryProductSku(String productId){
        return productSkuService.queyProductById(productId);
    }
}
